package cn.ekuma.epos.datalogic.define.dao.crm.concerns;

import cn.ekuma.data.dao.BaseDAO;
import cn.ekuma.epos.db.table.crm.concerns.I_ProductConcerns;
import com.openbravo.bean.crm.concerns.ProductConcerns;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

public class ProductConcernsDAO extends BaseDAO<ProductConcerns> {

	public ProductConcernsDAO(I_Session s) {
		super(s);
	}

	@Override
	public TableDefinition getTable() {
		return new TableDefinition( s,
                "CONCERNS_PRODUCT",
                new Field[]{
                    new Field(I_ProductConcerns.ID, Datas.STRING, Formats.STRING),
                    new Field(I_ProductConcerns.CONCERNSID, Datas.STRING, Formats.STRING),
                    new Field(I_ProductConcerns.PRODUCTID, Datas.STRING, Formats.STRING)  
                },
                new int[]{0});
	}

	@Override
	public void writeInsertValues(DataWrite dp, ProductConcerns obj)
			throws BasicException {
		dp.setString(1,obj.getKey());
		dp.setString(2, obj.getConcernsId());
		dp.setString(3,obj.getProductId());
		
	}

	@Override
	public Class getSuportClass() {
		return ProductConcerns.class;
	}

	@Override
	public ProductConcerns readValues(DataRead dr, ProductConcerns obj)
			throws BasicException {
		if(obj==null)
			obj=new ProductConcerns();
		obj.setKey(dr.getString(1));
		obj.setConcernsId(dr.getString(2));
		obj.setProductId(dr.getString(3));
		return obj;
	}
}
